home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / gpplib22.zoo / libsrc / xeh.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-30  |  776 b   |  45 lines

  1. /* Library code for programs which use -fhandle-exceptions.
  2.    Note: do *not* compile this with -fhandle-exceptions.  */
  3.  
  4.  
  5. #ifdef __GNUG__
  6. #pragma implementation
  7. #endif
  8. #include <setjmp.h>
  9. #include <stream.h>
  10. #include <osfcn.h>
  11.  
  12. struct
  13. ExceptionHandler
  14. {
  15.   ExceptionHandler *prev;
  16.   jmp_buf handler;
  17.   void *name;
  18.   void *parameters;
  19.   ExceptionHandler ();
  20.   ~ExceptionHandler ();
  21. } EHS, *exceptionHandlerStack = &EHS;
  22.  
  23. ExceptionHandler::ExceptionHandler ()
  24. {
  25.   if (this == &EHS)
  26.     {
  27.       if (setjmp (EHS.handler))
  28.     {
  29.       cerr << ("unhandled exception, aborting...\n");
  30.       abort ();
  31.     }
  32.     }
  33.   else
  34.     {
  35.       this->prev = exceptionHandlerStack;
  36.       exceptionHandlerStack = this;
  37.     }
  38. }
  39.  
  40. ExceptionHandler::~ExceptionHandler ()
  41. {
  42.   exceptionHandlerStack = this->prev;
  43. }
  44.  
  45.